package com.gitlab.lucky.common.utils;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

/**
 * @program: lucky
 * @author: Mr.Han
 * @create: 2019-03-22 13:57
 **/
public class CookieUtil {
    public static String getCookie(HttpServletRequest request, String name) {
        if (request==null||request.getCookies() == null) {
            return null;
        }
        for (Cookie cookie : request.getCookies()) {
            if (cookie.getName().equals(name)) {
                return cookie.getValue();
            }
        }
        return null;
    }
}
